package cn.parus.dynamicRouter.controller;

import cn.parus.commons.common.Result;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

/**
 * @Author: Axel
 * @Description: TODO
 **/
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/")
    public Result test() {
        try{
            return Result.success("你好，世界！！！");
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }


    public static void main(String[] args) {
//        WebClient webClient = WebClient.create("http://39.106.137.58:5050");
//        Mono<String> StringMono = webClient.get()
//                .uri("/v1/policies")
//                .retrieve()
//                .bodyToMono(String.class);
//        StringMono.subscribe(value -> System.out.println("获得的消息"+value));

        Mono<String> mono = Mono.just("hello");
        Mono<String> mono2 = mono.map(data -> data+" world!");
        mono2.subscribe(System.out::println);
    }
}
